package com.bdqn.controller;

import com.bdqn.entity.DataModel;
import com.bdqn.entity.Department;
import com.bdqn.entity.Goods;
import com.bdqn.entity.Parameters;
import com.bdqn.service.DepartmentManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class DepartmentManageController {
    @Autowired
    DepartmentManageService service;

    @RequestMapping(value = "DepartmentInfo")
    public DataModel<Department> getGoodsInfo(Parameters parameters){
        parameters.setPage((parameters.getPage()-1)*parameters.getLimit());
        DataModel<Department> dataModel=new DataModel<>();
        dataModel.setCode(0);
        dataModel.setMsg("");
        dataModel.setCount(service.getCount(parameters));
        dataModel.setData(service.getDepartmentInfo(parameters));
        return dataModel;
    }
    @RequestMapping(value = "delDepartmentInfoss")
    public int delDepartmentInfoss(@RequestParam(value="arr[]") int[] id){
        return service.delDepartmentInfoss(id);
    }
    @RequestMapping(value = "addDepartment")
    public int addGoodsInfo(Department department){
        return service.addDepartmentInfo(department);
    }

    @RequestMapping(value = "delDepartment")
    public int delGoodsInfo(int id){
        return service.delDepartmentInfo(id);
    }
    @RequestMapping(value = "updateDepartment")
    public int updateGoodsInfo(Department department){
        return service.updateDepartmentInfo(department);
    }

        @RequestMapping(value = "getDepartment")
    public List<Department> getDepartment(){
        return service.getDepartment();
    }
}
